import os


CMD = """
    cd FILE && 
    git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done && 
    git fetch --all && git pull --all && 
    cd ..
"""
for f in os.listdir('.'):
    if os.path.isdir(f):
        cmd = CMD.replace('FILE', f)
        print(f, cmd)
        os.system(cmd)